Skip to content

fix: quote trusted-types-eval and the other missing CSP keywords - #17490

Open
lprnmns wants to merge 2 commits into
sveltejs:mainfrom
lprnmns:fix/quote-csp-keywords
Open

lprnmns wants to merge 2 commits into
sveltejs:mainfrom
lprnmns:fix/quote-csp-keywords

Conversation

@lprnmns

@lprnmns lprnmns commented Oct 17, 2026 •

Copy link
Copy Markdown

#15938 added 'unsafe-allow-redirects', 'unsafe-webtransport-hashes' and 'trusted-types-eval' to the Csp.BaseSource type, but not to the quoted set in csp.js. So they are written into the header without quotes:

script-src 'self' trusted-types-eval

Browsers read an unquoted keyword as a host source named trusted-types-eval, and the keyword itself has no effect. The same goes for 'allow-duplicates' in the trusted-types directive (its type is 'none' | 'allow-duplicates' | '*' | string): unquoted, it is read as a policy name. This PR adds the four keywords to quoted.

An earlier version of this PR also re-enabled the prod CSP/cookie test suites, which Vitest 5's own process.env.DEV was skipping. #17436 has since fixed that on main, so I merged main and dropped that part. The PR now only touches csp.js, its spec and the changeset.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

The new quotes the other keyword sources test fails without the change to csp.js, with the keywords unquoted. The CSP and cookie specs (68 tests) and pnpm lint pass.

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 1c8d516:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/1c8d51699fbf7e6d2ac5423e7da78710d87379ee

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17490

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c8d516

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

# Conflicts:
#	packages/kit/src/runtime/server/cookie.spec.js
#	packages/kit/src/runtime/server/page/csp.spec.js
#	packages/kit/vitest.kit.config.js

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant